package com.zzh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzh.dao.ResourceMapper;
import com.zzh.domain.Resource;
import com.zzh.domain.ResourseVo;
import com.zzh.domain.Role;
import com.zzh.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResourceServiceImpl implements ResourceService {

    @Autowired
    private ResourceMapper resourceMapper;

    @Override
    public List<Role> findAllResourceCategory() {
        return resourceMapper.findAllResourceCategory();
    }

    @Override
    public PageInfo<Resource> findAllResource(ResourseVo resourseVo) {
        PageHelper.startPage(resourseVo.getCurrentPage(), resourseVo.getPageSize());
        List<Resource> resources = resourceMapper.findAllResource(resourseVo);
        PageInfo<Resource> pageInfo = new PageInfo<>(resources);
        return pageInfo;
    }
}
